import 'package:flutter/material.dart';

class AnimatedExample01Page extends StatefulWidget {
  const AnimatedExample01Page({super.key});

  @override
  State<AnimatedExample01Page> createState() => _AnimatedExample01PageState();
}

class _AnimatedExample01PageState extends State<AnimatedExample01Page> {
  bool flag = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Animated Example 01'),
      ),
      body: Center(
        child: AnimatedContainer(
          duration: const Duration(milliseconds: 1000),
          width: flag ? 200 : 300,
          height: flag ? 200 : 300,
          transform:
              flag ? Matrix4.rotationZ(0) : Matrix4.rotationZ(0.25 * 3.14),
          color: Colors.yellow,
          child: const Center(
            child: Text(
              "Hello World",
              style: TextStyle(
                color: Colors.white,
                fontSize: 20,
              ),
            ),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
